<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/12 0012
 * Time: 16:03
 */

namespace Cuke\Library\RateLimit;

/**
 * 实现流控的抽象类
 * @package Cuke\Library\RateLimit
 */
abstract class RateLimiter
{
    /**
     * @var \Redis
     */
    protected $redis;
    /**
     * @var string
     */
    protected $key;
    /**
     * @var string
     */
    protected $available_key;
    /**
     * @var string
     */
    protected $ts_key;
    /**
     * @var int
     */
    protected $timeout = 0;
    /**
     * @var int
     */
    protected $max_value;
    /**
     * @var float
     */
    protected $rate;

    /**
     * 获取授权
     * @param int $token 需要申请的令牌数量
     * @return bool
     */
    public abstract function access($token);
}